package com.guisu.material.progress

import android.graphics.Canvas
import android.graphics.Color
import android.graphics.ColorFilter
import android.graphics.Paint
import android.graphics.PixelFormat
import android.graphics.drawable.Drawable

class CircleDrawable: Drawable() {

    private val paint by lazy { Paint() }
    private var radius = 50f

    init {
        paint.apply {
            isDither = true
            isAntiAlias = true
            color = Color.RED
            style = Paint.Style.FILL
        }
    }

    override fun draw(canvas: Canvas) {
        val bounds = bounds
        val cx = bounds.centerX()
        val cy = bounds.centerY()
        canvas.drawCircle(cx.toFloat(), cy.toFloat(), radius, paint)
    }

    override fun setAlpha(alpha: Int) {
        paint.alpha = alpha
    }

    override fun setColorFilter(colorFilter: ColorFilter?) {
        paint.colorFilter= colorFilter
    }

    @Deprecated("Deprecated in Java")
    override fun getOpacity(): Int {
        return PixelFormat.TRANSLUCENT
    }
}